/**
 * 路由的配置文件
 * 好处：
 * 1. 模块化开发
 * 2. 方便后期维护和开发
 */
// 嵌套路由的父路由（一级路由）
import Layout from '@/views/layout'
// 按需加载（路由懒加载）=> 作用：访问的路由的时候加载当前路由的代码
// 四个标签页面组件（二级路由）
const Home = () => import('@/views/home')
const Question = () => import('@/views/question')
const Video = () => import('@/views/video')
const Profile = () => import('@/views/profile')
// 其它页面（登录、搜索等）（一级路由）
const Edit = () => import('@/views/user/edit')
const Chat = () => import('@/views/user/chat')
const Login = () => import('@/views/login')
const Search = () => import('@/views/search')
const SearchResult = () => import('@/views/search/result')
const Article = () => import('@/views/article')

// 路由配置数据
const routes = [
  // 标签页效果
  {
    path: '/',
    // name: 'Index',
    component: Layout,
    children: [
      // 二级路由
      {
        path: '/',
        name: 'Home',
        component: Home,
        meta: {
          isKeepAlive: true
        }
      },
      {
        path: '/question',
        name: 'Question',
        component: Question
      },
      {
        path: '/video',
        name: 'Video',
        component: Video
      },
      {
        path: '/user',
        name: 'User',
        component: Profile
      }
    ]
  },
  // 其它页面（登录、搜索等）（一级路由）
  {
    path: '/user/profile',
    name: 'Edit',
    component: Edit
  },
  {
    path: '/user/chat',
    name: 'Chat',
    component: Chat
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/search',
    name: 'Search',
    component: Search
  },
  {
    path: '/search/result',
    name: 'SearchResult',
    component: SearchResult
  },
  { path: '/article/:id', name: 'article', component: Article, meta: { keepalive: true } }
]
export default routes
